<?php /* @var $this Controller */ ?>
<?php
@ob_start();

//if (!Yii::app()->user->hasState('lang')) {
//    Yii::app()->user->setState('lang', 'en');
//    $local = Yii::app()->getLocale(Yii::app()->user->getState('lang'));
//} else {
//    if (isset($_REQUEST['lang'])) {
//        Yii::app()->user->setState('lang', $_REQUEST['lang']);
//        $local = Yii::app()->getLocale(Yii::app()->user->getState('lang'));
//    } else {
//        $local = Yii::app()->getLocale(Yii::app()->user->getState('lang'));
//    }
//}
//$cur_lang = Yii::app()->user->getState('lang');

// Setting Language

$session=new CHttpSession;
$session->open();

$http = new CHttpRequest;
Yii::app()->user->returnUrl = $http->getUrl();

$lang = Yii::app()->session['sess_lang'];
if (empty($lang)) {
    Yii::app()->language = 'th';
    $cur_lang='th';
} else {
    Yii::app()->language = $lang;
    $cur_lang = $lang;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="language" content="en" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />

        <!-- blueprint CSS framework -->
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" />
        <!--[if lt IE 8]>
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
        <![endif]-->

<!--        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />-->
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/bootstrap.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/shop-homepage.css" />
        <title><?php echo CHtml::encode($this->pageTitle); ?></title>
    </head>

    <body style="background: url('<?php echo Yii::app()->baseUrl; ?>/images/bg-big.jpg') fixed;">
        <?php
        $today = date('Y-n-j') . " 00:00:00";
        $dataProvider = new CActiveDataProvider('TblBanners', array(
            'criteria' => array(
                'condition' => 'banner_start_date <= ' . "'" . $today . "' AND banner_expire_date >=" . "'" . $today . "'"
            )
        ));
        $dataProvider->setPagination(false);
        $banner = array();
        $iterator = new CDataProviderIterator($dataProvider);
        foreach ($iterator as $data) {
            $banner[] = $data;
        }
        ?>
        <div class="container" id="page">
            <div id="header">
                <div class="carousel-holder">
                    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
                        <div id="Logo">
                            <img src="<?php echo Yii::app()->request->baseUrl; ?>/images/1.png" alt="" style="opacity:0.8; position:absolute; z-index:20; left: -15px; max-width:100%" />
                            <img src="<?php echo Yii::app()->request->baseUrl; ?>/images/2.png" alt="" style="position:absolute; z-index:21; left: -15px; max-width:100%" />
                        </div>
                        <div id="langBar" style="text-align:center ;background: url('<?php echo Yii::app()->baseUrl; ?>/images/language_bg.png') no-repeat;background-position: left;">
                            <?php 
                            if ($cur_lang == 'th') {
                                  echo CHtml::link('EN', array('setlanguage', 'lang'=>'en')); 
                            } else { 
                                echo CHtml::link('TH', array('setlanguage', 'lang'=>'th')); 
                            } ?>
                        </div>
                        <ol class="carousel-indicators">
                            <?php for ($i = 0; $i < count($banner); $i++) { ?>
                                <li data-target="#carousel-example-generic" data-slide-to="<?php echo $i; ?>" <?php if ($i == 0) { ?>class="active" <?php } ?>></li>
                            <?php } ?>
                        </ol>

                        <div class="carousel-inner">
                            <?php for ($i = 0; $i < count($banner); $i++) { ?>
                                <div class="item <?php if ($i == 0) { ?>active <?php } ?>">
                                    <img class="slide-image" src="<?php echo Yii::app()->request->baseUrl; ?>/images/<?php echo $banner[$i]->banner_picture; ?>" alt="" />
                                    <div class="carousel-caption">
                                        <p>
                                            <h5>
                                                <?php
                                                if ($cur_lang == 'en') {
                                                    echo $banner[$i]->banner_title_en;
                                                } else {
                                                    echo $banner[$i]->banner_title_th;
                                                }
                                                ?>
                                            </h5>
                                            <br/>
                                            <?php
                                            if ($cur_lang == 'en') {
                                                echo $banner[$i]->banner_content_en;
                                            } else {
                                                echo $banner[$i]->banner_content_th;
                                            }
                                            ?>
                                        </p>
                                    </div>
                                </div>
                            <?php } ?>
                        </div>
                    </div>
                </div>
            </div><!-- header -->


            <!-- ใช้สำหรับทำ Navigator -->
            <?php //if (isset($this->breadcrumbs)):  ?>
            <?php
            //$this->widget('zii.widgets.CBreadcrumbs', array(
            //    'links' => $this->breadcrumbs,
            //));
            ?><!-- breadcrumbs -->
            <?php //endif     ?>

            <?php echo $content; ?>

            <div class="clear"></div>
        </div><!-- page -->

        <div class="container" style = "background-color: transparent;"> 
            <div class="clear"></div>
            <div id="footer">
                <br/><br/>
                Copyright &copy; <?php echo date('Y'); ?> by MANDARIN GOLDEN VALLEY AND RESORT HOTEL (KHAO YAI).<br/>
                All Rights Reserved.<br/>
            </div><!-- footer -->
        </div>

        <!-- JavaScript -->
        <script src="<?php echo Yii::app()->theme->baseUrl; ?>/js/jquery-1.11.0.js"></script>
        <script src="<?php echo Yii::app()->theme->baseUrl; ?>/js/bootstrap.js"></script>
    </body>

</html>
